package com.mspbots.sync.wise.controller;

import com.fasterxml.jackson.databind.JsonNode;
import com.mspbots.sync.wise.service.CompanyService;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

import java.util.Map;

/**
 * com.mspbots.sync.wise.controller.CompanyController
 *
 * @author Alex bob(https://github.com/vnobo)
 * @date Created by 2019/11/19
 */
@Log4j2
@RestController
@RequiredArgsConstructor
@RequestMapping("companies")
public class CompanyController {

    private final CompanyService agreementService;

    @GetMapping("contacts")
    public Mono<JsonNode> getCompany(@RequestParam Map<String, String> params) {
        Assert.notNull(params.get("tenantId"), () -> "Search param tenant id not null.");
        return this.agreementService.getContacts(params);
    }

    @GetMapping("agreement")
    public Mono<Object> getAgreementId(@RequestParam Map<String, String> params) {
        Assert.notNull(params.get("tenantId"), () -> "Search param tenant id not null.");
        return this.agreementService.getAgreements(params);
    }

}
